package com.wl2o2o.collection.listnode;

import java.util.ArrayList;


public class 从尾到头打印链表 {
	public static void main(String[] args) {

		ListNode listNode = new ListNode(-1);
		ArrayList<Integer> res = new ArrayList<Integer>();
		//递归函数解决
		recursion(listNode, res);
		System.out.println(res);
	}
	//递归函数
	public static void recursion(ListNode head, ArrayList<Integer> res){
		if (head != null) {
			//先往链表深处遍历
			recursion(head.next, res);
			//再填充到数组就是逆序
			res.add(head.val);
		}
	}

}